//Kyle Marshall
//Assignment 4
//marshaky@onid.oregonstate.edu
//cs362

#include "dominion.h"
#include "dominion_helpers.h"
#include "rngs.h"
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <time.h>

//Embargo Card Random TestS

int main (int argc, char** argv) {
  struct gameState G;
  int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse, 
           sea_hag, tribute, smithy};
   int seed = 1000;
   int i, numPlayers, numTests, handPos, choice, numCoins, embtok;
   numPlayers = 4;

   memset(&G, 23, sizeof(struct gameState)); 
   //can vary number of players
   initializeGame(numPlayers, k, seed, &G);

   /*Test to make sure that the coins are incremented by 2,
  emargoTokens increment by 1, and function returns -1 if
  supplyCount is -1 with each call.
  */
  i = 0;
  numTests = 32;
  choice = 0;
  numCoins = numPlayers;
  embtok = G.embargoTokens[choice];
  while(i < numTests){
  	G.whoseTurn = rand() % numPlayers;
  	handPos = rand() % 5;
  	getEmbargo(choice,handPos,&G);
  	numCoins += 2;
  	embtok += 1;

  	if(embtok == G.embargoTokens[choice]){
  		printf("Embargo Tokens Test Passed\n");
  	}else{
  		printf("Embargo Tokens Test Failed\n");
  		exit(-1);
  	}


  	if(numCoins == G.coins){
  		printf("Num Coins Test Passed\n");
  	}else{
  		printf("Num Coins Test Failed\n");
  		printf("numcoins: %d\n\n", numCoins);
  		printf("G.coins: %d\n", G.coins );
  		exit(-1);
  	}
  	if(i+1 == numTests){
  		G.supplyCount[choice] = -1;
		if(getEmbargo(choice,handPos,&G) == -1){
			printf("supplyCount Fault Test Passed!\n");
		}else{
			printf("supplyCount Fault Test failed!\n");
			exit(-1);
		}

  	}
  	i++;
}

return 0;
}
